﻿using AutoMapper;
using Common.Communal;
using ERP.Domain.Processs;
using MediatR;
using Sell.Api.Write.Application.Command.Pro;
using Sell.Services.Pro;

namespace Sell.Api.Write.Application.CommandHandlers.Pro
{
    public class FlowUpdateCommandHandlers : IRequestHandler<FlowUpdateCommand, ApiResult<int>>
    {
        public IMapper Mapper { get; }
        public IFlowServices services { get; }
        public FlowUpdateCommandHandlers(IMapper _Mapper, IFlowServices _services)
        {
            Mapper = _Mapper;
            services = _services;
        }
        /// <summary>
        /// 工艺流程修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ApiResult<int>> Handle(FlowUpdateCommand request, CancellationToken cancellationToken)
        {
            var list = Mapper.Map<ProcessFlow>(request);
            return await services.UpdateProcessFlow(list);
        }
    }
}
